package com.qdh.demo7;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class DescIntWritable implements WritableComparable<DescIntWritable> {

    private int value;

    public DescIntWritable(int value) {
        this.value = value;
    }

    public DescIntWritable() {
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return ""+value;
    }

    @Override
    public int compareTo(DescIntWritable o) {
        int thisValue = this.value;
        int thatValue = o.value;
        return thisValue > thatValue ? -1 : (thisValue == thatValue ? 0 : 1);
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
            dataOutput.writeInt(value);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.value=dataInput.readInt();
    }
}
